﻿/*----------------------------------------------------------------
//  <copyright file="RoleController.cs" company="MicroCloud@151504200868">
//      Copyright © 2020-2024 MicroCloud Corporation, All rights reserved.
//  </copyright>
//  <site>https://gitee.com/chenmm123/microclouds</site>
//  <last-editor>cmm</last-editor>
//  <last-date>2023-11-22 15:06</last-date>
//----------------------------------------------------------------*/

namespace MicroCloud.Api.Authorization.Areas.Admin.Controllers.Identity
{
    #region "角色管理"
    /// <summary>
    /// 角色管理
    /// </summary>
    [Description("角色管理")]
    [ModuleInfo(Code = "Role", Name = "角色管理", OrderNo = 1, Position = "Identity", PositionName = "认证模块")]
    public class RoleController : AdminControllerBase
    {
        #region "属性"
        #region "获取 功能权限管理器"
        /// <summary>
        /// 获取 功能权限管理器
        /// </summary>
        protected FunctionAuthManager FunctionAuthManager => ServiceProvider.GetService<FunctionAuthManager>();
        #endregion

        #endregion

        #region "Action方法"
        #region "设置角色模块"
        /// <summary>
        /// 设置角色模块
        /// </summary>
        /// <param name="dto">角色模块信息</param>
        /// <returns>JSON操作结果</returns>
        [HttpPost]
        [ModuleInfo]
        [DependOnFunction("Read")]
        [DependOnFunction("ReadRoleModules", Controller = "Module")]
        [UnitOfWork]
        [Description("设置模块")]
        public virtual async Task<AjaxResult> SetModules(RoleSetModuleDto dto)
        {
            OperationResult result = await FunctionAuthManager.SetRoleModules(dto.RoleId, dto.ModuleIds);
            return result.ToAjaxResult();
        }
        #endregion

        #endregion

    }
    #endregion

}
